package com.epfresh.adapter;

import android.support.annotation.NonNull;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.epfresh.R;

import multitype.ItemViewBinder;

/**
 * Author: Chen
 * Date: 2019/4/29
 * Desc:
 */
public class ShowMoreGoodViewBinder extends ItemViewBinder<String,ShowMoreGoodViewBinder.ViewHolder> {
    private onShowMoreClickListener onShowMoreClickListener;

    public void setOnShowMoreClickListener(ShowMoreGoodViewBinder.onShowMoreClickListener onShowMoreClickListener) {
        this.onShowMoreClickListener = onShowMoreClickListener;
    }

    @NonNull
    @Override
    protected ViewHolder onCreateViewHolder(@NonNull LayoutInflater inflater, @NonNull ViewGroup parent) {
        View itemView = inflater.inflate(R.layout.item_show_more_goods,parent,false);
        return new ViewHolder(itemView);
    }

    @Override
    protected void onBindViewHolder(@NonNull ViewHolder holder, @NonNull String item) {
        holder.itemView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (onShowMoreClickListener != null) {
                    onShowMoreClickListener.showMoreClick();
                }
            }
        });
        holder.tv_center_number.setText(item);
    }

    static class ViewHolder extends RecyclerView.ViewHolder {
        private TextView tv_center_number;

        ViewHolder(View itemView) {
            super(itemView);
            tv_center_number = itemView.findViewById(R.id.tv_center_number);
        }
    }

    public interface onShowMoreClickListener {
        void showMoreClick();
    }

}
